package com.bee.bootstrap.system.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.bee.bootstrap.system.service.IAreaService;
import com.bee.common.core.result.Result;
import com.bee.bootstrap.system.entity.Area;
import com.bee.bootstrap.system.mapper.AreaMapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author liekkas
 * @since 2018-04-09
 */
@Service
public class AreaServiceImpl extends ServiceImpl<AreaMapper, Area> implements IAreaService {

    @Override
    public Result selectPageByParentId(long parentId) {
        Area condition=new Area();
        condition.setParentId(parentId);
        Page<Area> page = new Page<>();
        page.setSize(Integer.MAX_VALUE);
        EntityWrapper<Area> entityWrapper = new EntityWrapper(condition);
        return Result.success(this.selectPage(page,entityWrapper));
    }

    @Override
    public Area findByCode(String code) {
        Area condition=new Area();
        condition.setCode(code);
        return this.selectOne(new EntityWrapper<>(condition));
    }
}
